﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;

public partial class control_rounded_box_RoundedBox : System.Web.UI.UserControl
{
    private ITemplate _roundBoxTemplate = null;
    private string _theme = String.Empty;

    [TemplateContainer(typeof(ContentContainer))]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public ITemplate RoundBoxTemplate
    {
        get { return _roundBoxTemplate; }
        set { _roundBoxTemplate = value; }
    }

    public string Theme
    {
        get { return _theme; }
        set { _theme = value; }
    }

    protected void Page_Init()
    {
        if (_roundBoxTemplate != null)
        {
            RoundBoxContentContainer container = new RoundBoxContentContainer();
            _roundBoxTemplate.InstantiateIn(container);
            content.Controls.Add(container);

            // Adding the stylesheet for this control [note: path from page]
            HtmlLink cssLink = new HtmlLink();
            cssLink.Href = "~/control/rounded_box/themes/" + _theme + "/rounded_box.css";
            cssLink.Attributes.Add("rel", "Stylesheet");
            cssLink.Attributes.Add("type", "text/css");
            Page.Header.Controls.Add(cssLink);
        }
    }

    public override Control FindControl(string id)
    {
        return base.FindControl("content").Controls[0].FindControl(id);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        
    }  
}

public class RoundBoxContentContainer : Control, INamingContainer
{
    internal RoundBoxContentContainer() { }
}

